/*

Dofile: table6_appendix.do 

Date: Dec. 10, 2016 
Aim: Baseline regressions with standard errors clustered in alternative dimensions  

Input: base_for_reg.dta 
Outputs: 
 - table6_appendix_cluster_product.xls 
 - table6_appendix_cluster_productmode.xls 

 Reported in the online appendix: 
"Table A.6 – Baseline regression Effective Marginal Tax Rate, altern. clustering"

*/  

cd $datapath
use base_for_reg, clear 


drop cty_*
qui tab pays, g(cty_)

global name table6_cluster_productmode // name of the xls file where the results are sent 
egen product_mode=group(nc8 type) 
global tax_var inter_linvemtr linvemtr // tax variable and its interaction 
areg luv type $tax_var if tarif!=., absorb(fpt) vce(cluster product_mode)
outreg2  type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist  using  "$resultpath/$name.xls" ,  label e(all) nocons bdec(2) symbol($^{***}$, $^{**}$, $^{*}$) adjr2    replace 

areg luv type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist   , absorb(fpt) vce(cluster product_mode)
outreg2  type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist    using  "$resultpath/$name.xls" ,  label e(all) nocons bdec(2) symbol($^{***}$, $^{**}$, $^{*}$) adjr2    append 

global tax_var interdum_hines dum_hines
areg luv type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist  , absorb(fpt) vce(cluster product_mode)
outreg2  type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist    using  "$resultpath/$name.xls" ,  label e(all) nocons bdec(2) symbol($^{***}$, $^{**}$, $^{*}$) adjr2   append 

global tax_var interdum_hines dum_hines inter_linvemtr linvemtr 
areg luv type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist    , absorb(fpt) vce(cluster product_mode)
outreg2  type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist    using  "$resultpath/$name.xls" ,  label e(all) nocons bdec(2) symbol($^{***}$, $^{**}$, $^{*}$) adjr2   append 

areg luv type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist  if dum_hines==0, absorb(fpt) vce(cluster product_mode)
outreg2  type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist  using  "$resultpath/$name.xls" ,  label e(all) nocons bdec(2) symbol($^{***}$, $^{**}$, $^{*}$) adjr2    append 

global tax_var interdum_hines  inter_linvemtr // level variables not included - absorbed by the FE 
reghdfe luv type $tax_var inter_tarif inter_lgdpc inter_ldist  , absorb(fpt c) vce(cluster product_mode)
outreg2  type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist   using  "$resultpath/$name.xls" ,  label e(all) nocons bdec(2) symbol($^{***}$, $^{**}$, $^{*}$) adjr2    append 

global name table6_cluster_product // name of the xls file where the results are sent 
drop product_mode
egen product_mode=group(nc8) 
global tax_var inter_linvemtr linvemtr // tax variable and its interaction 
areg luv type $tax_var if tarif!=., absorb(fpt) vce(cluster product_mode)
outreg2  type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist  using  "$resultpath/$name.xls" ,  label e(all) nocons bdec(2) symbol($^{***}$, $^{**}$, $^{*}$) adjr2    replace 

areg luv type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist   , absorb(fpt) vce(cluster product_mode)
outreg2  type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist    using  "$resultpath/$name.xls" ,  label e(all) nocons bdec(2) symbol($^{***}$, $^{**}$, $^{*}$) adjr2    append 

global tax_var interdum_hines dum_hines
areg luv type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist  , absorb(fpt) vce(cluster product_mode)
outreg2  type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist    using  "$resultpath/$name.xls" ,  label e(all) nocons bdec(2) symbol($^{***}$, $^{**}$, $^{*}$) adjr2   append 

global tax_var interdum_hines dum_hines inter_linvemtr linvemtr 
areg luv type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist    , absorb(fpt) vce(cluster product_mode)
outreg2  type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist    using  "$resultpath/$name.xls" ,  label e(all) nocons bdec(2) symbol($^{***}$, $^{**}$, $^{*}$) adjr2   append 

areg luv type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist  if dum_hines==0, absorb(fpt) vce(cluster product_mode)
outreg2  type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist  using  "$resultpath/$name.xls" ,  label e(all) nocons bdec(2) symbol($^{***}$, $^{**}$, $^{*}$) adjr2    append 

global tax_var interdum_hines  inter_linvemtr // level variables not included - absorbed by the FE 
reghdfe luv type $tax_var inter_tarif inter_lgdpc inter_ldist  , absorb(fpt c) vce(cluster product_mode)
outreg2  type $tax_var inter_tarif tarif inter_lgdpc lgdpc inter_ldist ldist   using  "$resultpath/$name.xls" ,  label e(all) nocons bdec(2) symbol($^{***}$, $^{**}$, $^{*}$) adjr2    append 
